#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void test01()
{
    //char *arr[] = {"aaa", "bbb", "ccc", "ddd"};

#if 0
    char *p1 = "aaa";
    char *p2 = "bbb";
    char *p3 = "ccc";
    char *p4 = "ddd";

    char *arr[] = {p1, p2, p3, p4};
#endif
    //malloc返回的是首元素地址
    char **arr = malloc(sizeof(char*)*4);

    //char **arr = {p1, p2, p3, p4};
}

void printfArray1(int *arr, int len){}
void printfArray2(int (*arr)[3], int len){}
void printfArray3(int **arr, int len){}
void test02()
{
    //除了sizeof对数组名取地址这两种情况下，其他任何情况下数组名都是指向首元素的指针
    int arr1[10];
    printfArray1(arr1, 10);

    int arr2[3][3] = {
        {1,2,3},
        {3,4,5},
        {6,7,8},
    };

    printfArray2(arr2, 3);

    char *arr3 = {"aaa", "bbb", "ccc"};
    //arr3是什么类型 char**
    printfArray3(arr3, 3);

    char** arr4[3]; //arr4是什么类型? char***
}

void test03()
{
    typedef int (ARRAY_TYPE)[10];
    typedef int (*ARRAY_PONINT_TYPE)[10];

    int arr[10];
    int arr2[11];
    ARRAY_TYPE *p1 = &arr;
    ARRAY_PONINT_TYPE p2 = &arr;
    //p2 = &arr2;类型不一致  报错
    int (*p3)[10] = &arr; 

    //类型转换其本质是内存空间的大小的指定
    //对于指针类型进行类型转换其本质是指针步长的指定
}

struct Person
{
    char name[64];
    int age;
};
//只要结构体内部不涉及到指针,并且指针指向堆内存,那么使用默认操作没有问题

struct Teacher
{
    char *name;
    int age;
};

void test04()
{
    //结构体赋值
    struct Person p1;
    struct Person p2;
    p1 = p2;

    struct Teacher t1;
    struct Teacher  t2;
    //t1 = t2; //存在深拷贝和浅拷贝

}

int main(int argc, char const *argv[])
{

    return 0;
}